package math.leetcode_1823;

import java.util.ArrayList;
import java.util.List;

public class ListSolution {
    public int findTheWinner(int n, int k) {
        List<Integer> list = new ArrayList<>();
        for (int i = 1; i <= n; i++) {
            list.add(i);
        }
        int index = 0;
        while (n > 1) {
            index = (index + k - 1) % n;
            list.remove(index);
            n--;
        }
        return list.get(0);
    }
}
